<?php
session_start();
/*
 * Session variables:
 * $_SESSION['type'] [string] = user type of the logged in user
 * $_SESSION['authorised'] [boolean] = whether or not the current user is logged in

 */
if(isset($_SESSION['authorised']) && $_SESSION['authorised'] == true)
{   
    if(isset($_SESSION['type']))
    {
        if($_SESSION['type'] == 'administrator')
        {
			
			header('Location: admin_index.php');
            exit();
        }
        elseif($_SESSION['type'] == 'student')
        {
            header('Location: student_index.php');
            exit();
        }
        elseif($_SESSION['type'] == 'tutor')
        {
            header('Location: tutor_index.php');
            exit();
        }
        elseif($_SESSION['type'] == 'parent')
        {
           include ('connection.inc');
           $reservation_id = $_POST['reservation_id'];
           
           $sql = "DELETE FROM reservations WHERE reservation_id = '$reservation_id'";
           $result = pg_query($sql);
           
           //remove student from list reserved students in the class
           
           $_SESSION['message'] = "You just cancelled reservation # $reservation_id.";	
			header('Location: parent_viewreservations.php');
			exit();
			
        }
    }
}
else
{
    header('Location: index.php');
}
?>
